/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package avl.sv.shared.model.particleFeatureGenerator;

import avl.sv.shared.model.featureGenerator.AbstractFeatureGenerator;
import avl.sv.shared.model.featureGenerator.FeatureGeneratorImageJ;
import avl.sv.shared.model.featureGenerator.FeatureGeneratorOptionsPromptInterface;
import ij.Macro;
import ij.plugin.filter.Analyzer;

/**
 *
 * @author benbryan
 */
public class OptionsPromptImageJFeatures_Particle extends javax.swing.JPanel implements FeatureGeneratorOptionsPromptInterface  {

    FeatureGeneratorImageJ_Particle featureGeneratorImageJ_Particle = null;
    public OptionsPromptImageJFeatures_Particle(FeatureGeneratorImageJ_Particle featureGeneratorImageJ) {
        this.featureGeneratorImageJ_Particle = featureGeneratorImageJ;
        initComponents();
    }

    
    @Override
    public AbstractFeatureGenerator getFeatureGenerator() {
        return featureGeneratorImageJ_Particle;
    }
    
    /**
     * Creates new form OptionsPromptImageJFeatures
     */
    public OptionsPromptImageJFeatures_Particle() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jButtonLaunch = new javax.swing.JButton();

        jButtonLaunch.setText("Launch");
        jButtonLaunch.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonLaunchActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jButtonLaunch)
                .addContainerGap(323, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jButtonLaunch)
                .addContainerGap(266, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonLaunchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonLaunchActionPerformed
        Thread thread = Thread.currentThread();
        String name = thread.getName();
        if (!name.startsWith("Run$_")) {
            thread.setName("Run$_" + name);
        }
        Macro.setOptions(null);
        Analyzer.setMeasurements(featureGeneratorImageJ_Particle.getMeasurements());
        Analyzer as = new Analyzer();
        as.setup("set", null);
        featureGeneratorImageJ_Particle.setMeasurements(Analyzer.getMeasurements());
        Macro.setOptions("dummy");
    }//GEN-LAST:event_jButtonLaunchActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonLaunch;
    // End of variables declaration//GEN-END:variables
}
